.class public Lcom/netease/netstat/statistics/TcphandshakeHttpgetlatencyTest;
.super Lcom/netease/netstat/statistics/BaseTest;
.source "TcphandshakeHttpgetlatencyTest.java"


# direct methods
.method public constructor <init>(Landroid/telephony/TelephonyManager;Landroid/net/ConnectivityManager;Lcom/netease/netstat/utils/FileService;)V
    .locals 0
    .parameter "telephony"
    .parameter "connectivity"
    .parameter "file"

    .prologue
    .line 21
    invoke-direct {p0, p1, p2, p3}, Lcom/netease/netstat/statistics/BaseTest;-><init>(Landroid/telephony/TelephonyManager;Landroid/net/ConnectivityManager;Lcom/netease/netstat/utils/FileService;)V

    .line 22
    return-void
.end method


# virtual methods
.method public getTcpHttpLatency([Ljava/lang/String;)V
    .locals 24
    .parameter "server"

    .prologue
    .line 25
    const/16 v18, 0x0

    .line 26
    .local v18, tcpSocket:Ljava/net/Socket;
    const/4 v12, 0x0

    .line 27
    .local v12, os:Ljava/io/DataOutputStream;
    const/4 v9, 0x0

    .line 28
    .local v9, is:Ljava/io/DataInputStream;
    const-wide/16 v16, 0x0

    .local v16, strTime:J
    const-wide/16 v6, 0x0

    .line 29
    .local v6, endTime:J
    const/4 v3, 0x0

    .line 30
    .local v3, averagetcpLandmarkServers:I
    const/4 v2, 0x0

    .line 31
    .local v2, averageHTTPGETLandmarkServers:I
    sget-boolean v20, Lcom/netease/netstat/utils/Contanst;->airline:Z

    if-nez v20, :cond_1

    sget-boolean v20, Lcom/netease/netstat/utils/Contanst;->connectivity:Z

    if-eqz v20, :cond_1

    .line 32
    const/4 v8, 0x0

    .local v8, i:I
    :goto_0
    move-object/from16 v0, p1

    array-length v0, v0

    move/from16 v20, v0

    move/from16 v0, v20

    if-lt v8, v0, :cond_2

    .line 102
    move-object/from16 v0, p1

    array-length v0, v0

    move/from16 v20, v0

    const/16 v21, 0x1

    move/from16 v0, v20

    move/from16 v1, v21

    if-le v0, v1, :cond_1

    .line 103
    if-eqz v3, :cond_0

    .line 105
    move-object/from16 v0, p1

    array-length v0, v0

    move/from16 v20, v0

    .line 104
    div-int v20, v3, v20

    move/from16 v0, v20

    int-to-long v0, v0

    move-wide/from16 v20, v0

    invoke-static/range {v20 .. v21}, Lcom/netease/netstat/utils/Contanst;->setTcphandshake(J)V

    .line 109
    :cond_0
    if-eqz v2, :cond_1

    .line 111
    move-object/from16 v0, p1

    array-length v0, v0

    move/from16 v20, v0

    .line 110
    div-int v20, v2, v20

    invoke-static/range {v20 .. v20}, Lcom/netease/netstat/utils/Contanst;->setHttpgetlatency(I)V

    .line 115
    .end local v8           #i:I
    :cond_1
    return-void

    .line 35
    .restart local v8       #i:I
    :cond_2
    :try_start_0
    new-instance v19, Ljava/net/Socket;

    invoke-direct/range {v19 .. v19}, Ljava/net/Socket;-><init>()V
    :try_end_0
    .catch Ljava/net/UnknownHostException; {:try_start_0 .. :try_end_0} :catch_6
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_2

    .line 36
    .end local v18           #tcpSocket:Ljava/net/Socket;
    .local v19, tcpSocket:Ljava/net/Socket;
    :try_start_1
    new-instance v15, Ljava/net/InetSocketAddress;

    .line 37
    aget-object v20, p1, v8

    const/16 v21, 0x50

    .line 36
    move-object/from16 v0, v20

    move/from16 v1, v21

    invoke-direct {v15, v0, v1}, Ljava/net/InetSocketAddress;-><init>(Ljava/lang/String;I)V

    .line 38
    .local v15, remoteAddr:Ljava/net/SocketAddress;
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v16

    .line 39
    const/16 v20, 0x7d0

    move-object/from16 v0, v19

    move/from16 v1, v20

    invoke-virtual {v0, v15, v1}, Ljava/net/Socket;->connect(Ljava/net/SocketAddress;I)V

    .line 40
    const/16 v20, 0x1388

    invoke-virtual/range {v19 .. v20}, Ljava/net/Socket;->setSoTimeout(I)V

    .line 41
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v6

    .line 44
    int-to-long v0, v3

    move-wide/from16 v20, v0

    sub-long v22, v6, v16

    add-long v20, v20, v22

    move-wide/from16 v0, v20

    long-to-int v3, v0

    .line 45
    aget-object v20, p1, v8

    const-string v21, "c.3g.163.com"

    invoke-virtual/range {v20 .. v21}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v20

    if-eqz v20, :cond_3

    .line 48
    sub-long v20, v6, v16

    invoke-static/range {v20 .. v21}, Lcom/netease/netstat/utils/Contanst;->setTcphandshake163(J)V

    .line 50
    :cond_3
    new-instance v13, Ljava/io/DataOutputStream;

    invoke-virtual/range {v19 .. v19}, Ljava/net/Socket;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v20

    move-object/from16 v0, v20

    invoke-direct {v13, v0}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V
    :try_end_1
    .catch Ljava/net/UnknownHostException; {:try_start_1 .. :try_end_1} :catch_7
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_3

    .line 51
    .end local v12           #os:Ljava/io/DataOutputStream;
    .local v13, os:Ljava/io/DataOutputStream;
    :try_start_2
    new-instance v10, Ljava/io/DataInputStream;

    invoke-virtual/range {v19 .. v19}, Ljava/net/Socket;->getInputStream()Ljava/io/InputStream;

    move-result-object v20

    move-object/from16 v0, v20

    invoke-direct {v10, v0}, Ljava/io/DataInputStream;-><init>(Ljava/io/InputStream;)V
    :try_end_2
    .catch Ljava/net/UnknownHostException; {:try_start_2 .. :try_end_2} :catch_8
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_4

    .line 52
    .end local v9           #is:Ljava/io/DataInputStream;
    .local v10, is:Ljava/io/DataInputStream;
    const/16 v20, 0x7d0

    :try_start_3
    invoke-virtual/range {v19 .. v20}, Ljava/net/Socket;->setSoTimeout(I)V

    .line 53
    const/16 v20, 0x1

    invoke-virtual/range {v19 .. v20}, Ljava/net/Socket;->setTcpNoDelay(Z)V
    :try_end_3
    .catch Ljava/net/UnknownHostException; {:try_start_3 .. :try_end_3} :catch_9
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_5

    move-object v9, v10

    .end local v10           #is:Ljava/io/DataInputStream;
    .restart local v9       #is:Ljava/io/DataInputStream;
    move-object v12, v13

    .end local v13           #os:Ljava/io/DataOutputStream;
    .restart local v12       #os:Ljava/io/DataOutputStream;
    move-object/from16 v18, v19

    .line 60
    .end local v15           #remoteAddr:Ljava/net/SocketAddress;
    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    :goto_1
    if-eqz v18, :cond_8

    if-eqz v12, :cond_8

    if-eqz v9, :cond_8

    .line 63
    new-instance v20, Ljava/lang/StringBuilder;

    const-string v21, "GET /index.html HTTP/1.1\r\nHost:"

    invoke-direct/range {v20 .. v21}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 64
    aget-object v21, p1, v8

    invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v20

    .line 65
    const-string v21, "\r\nAccept-Encoding: gzip\r\n\r\n"

    invoke-virtual/range {v20 .. v21}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v20

    .line 63
    invoke-virtual/range {v20 .. v20}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    .line 67
    .local v4, buf:Ljava/lang/String;
    invoke-virtual {v4}, Ljava/lang/String;->getBytes()[B

    move-result-object v11

    .line 68
    .local v11, message:[B
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v6

    .line 70
    const v20, 0x186a0

    :try_start_4
    move/from16 v0, v20

    new-array v5, v0, [B

    .line 71
    .local v5, buffer:[B
    const/4 v14, 0x0

    .line 72
    .local v14, read_bytes:I
    invoke-virtual {v12, v11}, Ljava/io/DataOutputStream;->write([B)V

    .line 74
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v16

    .line 76
    :cond_4
    const/16 v20, 0x0

    const v21, 0x186a0

    move/from16 v0, v20

    move/from16 v1, v21

    invoke-virtual {v9, v5, v0, v1}, Ljava/io/DataInputStream;->read([BII)I

    move-result v14

    .line 77
    const/16 v20, -0x1

    move/from16 v0, v20

    if-eq v14, v0, :cond_5

    .line 78
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v6

    .line 79
    const/16 v20, 0x3e8

    move-object/from16 v0, v18

    move/from16 v1, v20

    invoke-virtual {v0, v1}, Ljava/net/Socket;->setSoTimeout(I)V
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_1

    .line 81
    :cond_5
    if-gtz v14, :cond_4

    .line 85
    .end local v5           #buffer:[B
    .end local v14           #read_bytes:I
    :goto_2
    cmp-long v20, v6, v16

    if-lez v20, :cond_6

    .line 86
    int-to-long v0, v2

    move-wide/from16 v20, v0

    sub-long v22, v6, v16

    add-long v20, v20, v22

    move-wide/from16 v0, v20

    long-to-int v2, v0

    .line 88
    :cond_6
    aget-object v20, p1, v8

    const-string v21, "c.3g.163.com"

    invoke-virtual/range {v20 .. v21}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v20

    if-eqz v20, :cond_7

    .line 91
    sub-long v20, v6, v16

    move-wide/from16 v0, v20

    long-to-int v0, v0

    move/from16 v20, v0

    move/from16 v0, v20

    int-to-long v0, v0

    move-wide/from16 v20, v0

    invoke-static/range {v20 .. v21}, Lcom/netease/netstat/utils/Contanst;->setHttpgetlatency163(J)V

    .line 94
    :cond_7
    :try_start_5
    invoke-virtual/range {v18 .. v18}, Ljava/net/Socket;->close()V

    .line 95
    invoke-virtual {v12}, Ljava/io/DataOutputStream;->close()V

    .line 96
    invoke-virtual {v9}, Ljava/io/DataInputStream;->close()V
    :try_end_5
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_5} :catch_0

    .line 32
    .end local v4           #buf:Ljava/lang/String;
    .end local v11           #message:[B
    :cond_8
    :goto_3
    add-int/lit8 v8, v8, 0x1

    goto/16 :goto_0

    .line 97
    .restart local v4       #buf:Ljava/lang/String;
    .restart local v11       #message:[B
    :catch_0
    move-exception v20

    goto :goto_3

    .line 82
    :catch_1
    move-exception v20

    goto :goto_2

    .line 56
    .end local v4           #buf:Ljava/lang/String;
    .end local v11           #message:[B
    :catch_2
    move-exception v20

    goto/16 :goto_1

    .end local v18           #tcpSocket:Ljava/net/Socket;
    .restart local v19       #tcpSocket:Ljava/net/Socket;
    :catch_3
    move-exception v20

    move-object/from16 v18, v19

    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    goto/16 :goto_1

    .end local v12           #os:Ljava/io/DataOutputStream;
    .end local v18           #tcpSocket:Ljava/net/Socket;
    .restart local v13       #os:Ljava/io/DataOutputStream;
    .restart local v15       #remoteAddr:Ljava/net/SocketAddress;
    .restart local v19       #tcpSocket:Ljava/net/Socket;
    :catch_4
    move-exception v20

    move-object v12, v13

    .end local v13           #os:Ljava/io/DataOutputStream;
    .restart local v12       #os:Ljava/io/DataOutputStream;
    move-object/from16 v18, v19

    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    goto/16 :goto_1

    .end local v9           #is:Ljava/io/DataInputStream;
    .end local v12           #os:Ljava/io/DataOutputStream;
    .end local v18           #tcpSocket:Ljava/net/Socket;
    .restart local v10       #is:Ljava/io/DataInputStream;
    .restart local v13       #os:Ljava/io/DataOutputStream;
    .restart local v19       #tcpSocket:Ljava/net/Socket;
    :catch_5
    move-exception v20

    move-object v9, v10

    .end local v10           #is:Ljava/io/DataInputStream;
    .restart local v9       #is:Ljava/io/DataInputStream;
    move-object v12, v13

    .end local v13           #os:Ljava/io/DataOutputStream;
    .restart local v12       #os:Ljava/io/DataOutputStream;
    move-object/from16 v18, v19

    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    goto/16 :goto_1

    .line 54
    .end local v15           #remoteAddr:Ljava/net/SocketAddress;
    :catch_6
    move-exception v20

    goto/16 :goto_1

    .end local v18           #tcpSocket:Ljava/net/Socket;
    .restart local v19       #tcpSocket:Ljava/net/Socket;
    :catch_7
    move-exception v20

    move-object/from16 v18, v19

    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    goto/16 :goto_1

    .end local v12           #os:Ljava/io/DataOutputStream;
    .end local v18           #tcpSocket:Ljava/net/Socket;
    .restart local v13       #os:Ljava/io/DataOutputStream;
    .restart local v15       #remoteAddr:Ljava/net/SocketAddress;
    .restart local v19       #tcpSocket:Ljava/net/Socket;
    :catch_8
    move-exception v20

    move-object v12, v13

    .end local v13           #os:Ljava/io/DataOutputStream;
    .restart local v12       #os:Ljava/io/DataOutputStream;
    move-object/from16 v18, v19

    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    goto/16 :goto_1

    .end local v9           #is:Ljava/io/DataInputStream;
    .end local v12           #os:Ljava/io/DataOutputStream;
    .end local v18           #tcpSocket:Ljava/net/Socket;
    .restart local v10       #is:Ljava/io/DataInputStream;
    .restart local v13       #os:Ljava/io/DataOutputStream;
    .restart local v19       #tcpSocket:Ljava/net/Socket;
    :catch_9
    move-exception v20

    move-object v9, v10

    .end local v10           #is:Ljava/io/DataInputStream;
    .restart local v9       #is:Ljava/io/DataInputStream;
    move-object v12, v13

    .end local v13           #os:Ljava/io/DataOutputStream;
    .restart local v12       #os:Ljava/io/DataOutputStream;
    move-object/from16 v18, v19

    .end local v19           #tcpSocket:Ljava/net/Socket;
    .restart local v18       #tcpSocket:Ljava/net/Socket;
    goto/16 :goto_1
.end method
